#[cfg(test)]
mod tests {
    use hyper_net::prelude::{async_ops::download_image, is_image_url};
    use std::io::Write;

    #[test]
    fn test_download_image() {
        let url = "https://i.pinimg.com/564x/9b/a2/57/9ba25796112cad616be27e473ae1e149.jpg";
        let result = tokio_test::block_on(download_image(url)).expect("异步测试下载失败");

        let tmp = tempfile::tempdir().expect("创建临时目录失败");
        let output_name = tmp.path().join("test.jpg");
        let output_filename = output_name.to_str().expect("转换路径失败");
        println!("output_name:{}", &output_filename);
        let mut file = std::fs::File::create(output_filename).expect("无法创建文件");
        let _ = file.write_all(&result);
        assert!(result.len() > 0);
    }
    #[test]
    fn test_is_image_url() {
        let url = vec![
            "https://example.com/image.jpg",
            "https://i.pinimg.com/564x/9b/a2/57/9ba25796112cad616be27e473ae1e149.jpg",
        ];
        for e in url {
            assert!(is_image_url(&e));
        }
    }
}
